package com.fastwire.carriere.inventory.vo;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

import com.fastwire.carriere.common.constant.HuaweiInventoryConstants;
import com.fastwire.carriere.common.mapper.TPNameMapper;
import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.inventory.entity.CrossConnect;
import com.fastwire.carriere.inventory.entity.FDFr;
import com.fastwire.carriere.inventory.entity.NetworkElement;
import com.fastwire.carriere.rad.entityVo.RadVo;

// TODO: Auto-generated Javadoc
/**
 * The Class EndVo.
 */
@Root(name = "EndVo")
public class EndVo {

	/** The node vo. */
	@Element(name = "NE", required = false)
	private NetworkElementVo neVo;
    	
	@Element(name = "aendTp", required = false)
	private String aendTp;
	@Element(name = "zendTp", required = false)
	private String zendTp;
	@Element(name = "IngressLsrID", required = false)
	private String ingressLsrID;
	@Element(name = "EgressLsrID", required = false)
	private String egressLsrID;
	@Element(name = "PBS", required = false)
	private String pbs;
	@Element(name = "CBS", required = false)
	private String cbs;
	@Element(name = "NextHop", required = false)
	private String nextHop;
	@Element(name = "Direction", required = false)
	private String direction;
	@Element(name = "State", required = false)
	private String fdfrState;
	@Element(name = "Type", required = false)
	private String fdfrType;

	/**
	 * Instantiates a new end vo.
	 */
	public EndVo() {
		super();

	}

	// added by Jun on 20120510
	public EndVo(RadVo rad) {
        super();
        this.neVo = new NetworkElementVo();
        neVo.setIpAddress(rad.getIpAddr());
        neVo.setName(rad.getSysName());
        neVo.setNativeEmsName(rad.getSysName());
        neVo.setNeType(rad.getType());
        neVo.setSoftwareVersion(rad.getSwVersion());
    }
	
	/**
	 * Instantiates a new end vo.
	 * 
	 * @param ne
	 *            the ne
	 */
	public EndVo(NetworkElement ne) {
		super();
		this.neVo = new NetworkElementVo(ne);
	}

	public EndVo(NetworkElement ne, CrossConnect cc) {
		super();
		this.neVo = new NetworkElementVo(ne);
		try {
			this.aendTp = TPNameMapper.getReadableTpName(cc.getAendTp()
					.getName(), cc.getAendTp().getType(), ne);
			this.zendTp = TPNameMapper.getReadableTpName(cc.getZendTp()
					.getName(), cc.getZendTp().getType(), ne);

			this.egressLsrID = cc.getTransmissionParameterbyLR(
					HuaweiInventoryConstants.LayerRate_MPLS_Path).getParameter(
					HuaweiInventoryConstants.CC_EgressLsrID);

			this.ingressLsrID = cc.getTransmissionParameterbyLR(
					HuaweiInventoryConstants.LayerRate_MPLS_Path).getParameter(
					HuaweiInventoryConstants.CC_IngressLsrID);
			this.pbs = cc.getTransmissionParameterbyLR(
					HuaweiInventoryConstants.LayerRate_MPLS_Path).getParameter(
					HuaweiInventoryConstants.CC_PBS);
			this.cbs = cc.getTransmissionParameterbyLR(
					HuaweiInventoryConstants.LayerRate_MPLS_Path).getParameter(
					HuaweiInventoryConstants.CC_CBS);
			this.nextHop = cc.getTransmissionParameterbyLR(
					HuaweiInventoryConstants.LayerRate_MPLS_Path).getParameter(
					HuaweiInventoryConstants.CC_NextHop);

			this.direction = cc.getDirection();

		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public EndVo(NetworkElement ne, FDFr fdfr) {
		super();
		this.neVo = new NetworkElementVo(ne);
		try {
			this.aendTp = TPNameMapper.getReadableTpName(fdfr.getAendTp()
					.getName(), fdfr.getAendTp().getType(), ne);
			this.zendTp = TPNameMapper.getReadableTpName(fdfr.getZendTp()
					.getName(), fdfr.getZendTp().getType(), ne);
			this.direction = fdfr.getDirection();
			this.fdfrState = fdfr.getFdfrState();
			this.fdfrType = fdfr.getFdfrType();

		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public NetworkElementVo getNeVo() {
		return neVo;
	}

	public void setNeVo(NetworkElementVo neVo) {
		this.neVo = neVo;
	}

	public String getAendTp() {
		return aendTp;
	}

	public void setAendTp(String aendTp) {
		this.aendTp = aendTp;
	}

	public String getZendTp() {
		return zendTp;
	}

	public void setZendTp(String zendTp) {
		this.zendTp = zendTp;
	}

	public String getIngressLsrID() {
		return ingressLsrID;
	}

	public void setIngressLsrID(String ingressLsrID) {
		this.ingressLsrID = ingressLsrID;
	}

	public String getEgressLsrID() {
		return egressLsrID;
	}

	public void setEgressLsrID(String egressLsrID) {
		this.egressLsrID = egressLsrID;
	}

	public String getPbs() {
		return pbs;
	}

	public void setPbs(String pbs) {
		this.pbs = pbs;
	}

	public String getCbs() {
		return cbs;
	}

	public void setCbs(String cbs) {
		this.cbs = cbs;
	}

	public String getNextHop() {
		return nextHop;
	}

	public void setNextHop(String nextHop) {
		this.nextHop = nextHop;
	}

	public String getDirection() {
		return direction;
	}

	public void setDirection(String direction) {
		this.direction = direction;
	}

	public String getFdfrState() {
		return fdfrState;
	}

	public void setFdfrState(String fdfrState) {
		this.fdfrState = fdfrState;
	}

	public String getFdfrType() {
		return fdfrType;
	}

	public void setFdfrType(String fdfrType) {
		this.fdfrType = fdfrType;
	}
}
